package com.axjy.web;

import com.axjy.pojo.User;
import com.axjy.service.UserService;
import java.util.List;

import com.axjy.util.Log;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.Resources;

/**
 * Created by zjn on 2018/2/6.
 */
@RestController
@RequestMapping("/user/user")
public class UserHandler {

    @Resource
    private UserService userService;

    @GetMapping("/list")
    public List<User> list(){
        return userService.list();
    }


    @PostMapping("/grant")
    public String gtant(Integer roleId,Integer id){
        String msg=null;
        try{
            userService.grant(roleId,id);
            msg="授权成功";
        }catch (RuntimeException ex){
            msg="授权失败";
            Log.logger.error(ex);
        }
            return msg;
    }





}
